package com.winshare.saleAssistant.controller;

import com.winshare.saleAssistant.domain.dto.req.FeedbackCreateDTO;
import com.winshare.saleAssistant.domain.dto.req.FeedbackIdDTO;
import com.winshare.saleAssistant.domain.dto.req.FeedbackQueryDTO;
import com.winshare.saleAssistant.domain.dto.req.FeedbackReplyDTO;
import com.winshare.saleAssistant.service.FeedbackService;
import com.winshare.saleAssistant.util.LogicResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/feedback")
@CrossOrigin
@Api(value = "反馈信息", description = "反馈信息")
public class FeedbackController {

    private final FeedbackService feedbackService;

    public FeedbackController(FeedbackService feedbackService) {
        this.feedbackService = feedbackService;
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增反馈信息接口",notes = "新增反馈信息接口")
    public LogicResponse save(@RequestBody @Validated FeedbackCreateDTO feedbackCreateDTO) {
        feedbackService.save(feedbackCreateDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/set/read")
    @ApiOperation(value = "设置已读信息接口",notes = "设置已读信息接口")
    public LogicResponse setRead(@RequestBody @Validated FeedbackIdDTO feedbackIdDTO) {
        feedbackService.setRead(feedbackIdDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/reply")
    @ApiOperation(value = "回复信息接口",notes = "回复信息接口")
    public LogicResponse reply(@RequestBody @Validated FeedbackReplyDTO feedbackReplyDTO) {
        feedbackService.reply(feedbackReplyDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/list")
    @ApiOperation(value = "获取反馈信息列表",notes = "获取反馈信息列表")
    public LogicResponse reply(@RequestBody @Validated FeedbackQueryDTO feedbackQueryDTO) {
        return LogicResponse.success(feedbackService.getFeedBackList(feedbackQueryDTO));
    }
}
